//Monday, November 30 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class OrderedSuperString
{
public:
	int getLength(vector <string> words)
	{
		string ret = "";
		for(int i=0; i<words.size(); i++)
		{
			int temp = cost(ret, words[i]);
			ret += words[i].substr(temp);
			cout << temp << ", " << ret << endl;
		}
		return ret.size();
	}
	int cost(string a, string b)
	{
		int i = 0;
		for(i=1; i<=b.size() && i<=a.size(); i++)
		{
// 			cout << a.substr(a.size()-i);
// 			cout << ", ";
// 			cout << b.substr(0,i) << endl;
			if(a.substr(a.size()-i) != b.substr(0,i))
				return i-1;
		}
		if(i>0) return min(a.size(), b.size());
		return 0;
	}
};